import { useState } from 'react';

/**
 * @description useCollapseChange 折叠面板操作
 * @param activeKeys 折叠面板所有 key
 * @return activeKey 当前激活的折叠面板 key
 * @return changeActiveKey 折叠面板回调
 */
export function useCollapseChange({ activeKeys }: { activeKeys: any }) {
  const [activeKey, setActiveKey] = useState<string[]>(activeKeys);

  const changeActiveKey = (keys: string | string[]) => {
    setActiveKey(Array.isArray(keys) ? keys : [keys]);
  };

  return {
    activeKey,
    changeActiveKey,
  };
}
